+ function($, win) {
    var throttle = function(fn, delay) {
        var timer = null;
        return function() {
            var context = this,
                args = arguments;
            clearTimeout(timer);
            timer = setTimeout(function() {
                fn.apply(context, args);
            }, delay);
        };
    };
    
    var minw = 0,
        $media = $('#J_slider_box');
    var w = $media.find('li').length * 240+42,
        docWidth = $('#J_slider').width();
    var $left = $('#J_MediaPrev');
    var $right = $('#J_MediaNext');
    var index = 0;

    $media.css({
        width: w
    });
    $left.on('click', function() {
        if (minw >= 0) return;
        index--;
        var index_w = $media.find('li').eq(index).width()+2;
        if (minw + index_w >= 0) {
            $left.hide();
        } else {
            $right.show();
        }
        $media.animate({
            marginLeft: minw += index_w
        });
    });

    $right.on('click', function() {
        if (docWidth - minw >= w) return;
        var index_w = $media.find('li').eq(index).width()+2;
        if (docWidth - minw >= w - index_w) {
            $right.hide();
        } else {
            $left.show();
        }
        $media.animate({
            marginLeft: minw -= index_w
        });
        index++;
    });


    var $tenNavBox = $('#J_side_nav');
    $(window).on('scroll', function() {
        throttle(function() {
            if ($(document).scrollTop() > 400) {
                $tenNavBox.show();
            } else {
                $tenNavBox.hide();
            }
        }(), 100);
    });
    $tenNavBox.find('.top').on('click',function(){
        $('body,html').animate({scrollTop:0},500);
        return false;
    });

}(jQuery, window)
